package com.dhh.sky.widget;

import com.dhh.sky.R;
import com.dhh.sky.activity.CameraActivity;
import com.dhh.sky.activity.DownloadsActivity;
import com.dhh.sky.activity.FileListActivity;
import com.dhh.sky.activity.SettingActivity;
import com.dhh.sky.activity.SongListActivity;
import com.dhh.sky.util.Constant;
import com.slidingmenu.lib.app.SlidingFragmentActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class SlideMenuFragment extends Fragment implements View.OnClickListener{
	private View lFiles;
	private View lResent;
	private View lMusic;
	private View lCamera;
	private View lSetting;
	private View lDownlaod;
	private View lShared;
	
	
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.slide_menu, null);
		initView(view);
		return view;
	}
	
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}
	
	private void initView(View container){
		lFiles = container.findViewById(R.id.sl_files);
		lFiles.setOnClickListener(this);
		lResent = container.findViewById(R.id.sl_resent_doc);
		lResent.setOnClickListener(this);
		lMusic = container.findViewById(R.id.sl_music);
		lMusic.setOnClickListener(this);
		lCamera = container.findViewById(R.id.sl_camera);
		lCamera.setOnClickListener(this);
		lSetting = container.findViewById(R.id.sl_setting);
		lSetting.setOnClickListener(this);
		lDownlaod = container.findViewById(R.id.sl_share);
		lDownlaod.setOnClickListener(this);
		lShared = container.findViewById(R.id.sl_shared);
		lShared.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {	
		SlidingFragmentActivity activity = (SlidingFragmentActivity) this.getActivity();
		Intent intent = new Intent(this.getActivity(),FileListActivity.class);
		
		if(R.id.sl_files == v.getId()){
			intent = new Intent(this.getActivity(),FileListActivity.class);
		}else if(R.id.sl_resent_doc == v.getId()){
			intent = new Intent(this.getActivity(),FileListActivity.class);
			intent.putExtra(Constant.PARAM_PATH, Constant.SKYFRIVE_PATH_RECENT_DOCS);
		}else if(R.id.sl_music == v.getId()){
			intent = new Intent(this.getActivity(),SongListActivity.class);
		}else if(R.id.sl_camera == v.getId()){
			intent = new Intent(this.getActivity(),CameraActivity.class);
		}else if(R.id.sl_setting == v.getId()){
			intent = new Intent(this.getActivity(),SettingActivity.class);
		}else if(R.id.sl_shared == v.getId()){
			intent = new Intent(this.getActivity(),FileListActivity.class);
			intent.putExtra(Constant.PARAM_PATH, Constant.SKYFRIVE_PATH_SHARED);
		}else if(R.id.sl_share == v.getId()){
			intent = new Intent(this.getActivity(),DownloadsActivity.class);
		}		

		this.getActivity().startActivity(intent);
		activity.toggle();
	}
}
